'use strict';

module.exports = app => {
  const { STRING, INTEGER, DATE, BOOLEAN } = app.Sequelize;

  const Task = app.model.define('task', {
    id: { 
      type: INTEGER, 
      primaryKey: true, 
      autoIncrement: true,
      allowNull: false
    },
    // 每次打卡上传的图片（图片路径）
    task_images: {
        type: STRING,
        allowNull: true
    },
    // 完成听写
    finish_write: {
        type: BOOLEAN,
        allowNull: false,
        defaultValue: false
    },
    // 完成视频
    finish_video: {
        type: BOOLEAN,
        allowNull: false,
        defaultValue: false
    },
    created_at: DATE,
    updated_at: DATE
  })
  Task.associate = function() {
    app.model.Task.belongsTo(app.model.User, {
      foreignKey: {
        name: 'sign_id',
        allowNull: true
      },
      targetKey: 'id'
    })
  };
  return Task;
};